package byx.container.annotation.extension.impl;

import byx.container.annotation.annotation.Conditional;
import byx.container.core.Container;
import byx.container.core.utils.ReflectUtils;

import java.util.function.Predicate;

public class ConditionalHandler extends ConditionalAnnotationHandler<Conditional> {
    @Override
    public boolean needToRegister(Conditional annotation, Container container) {
        Class<? extends Predicate<Container>> predicateType = annotation.value();
        Predicate<Container> predicate = ReflectUtils.createByDefaultConstructor(predicateType);
        return predicate.test(container);
    }
}
